home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc20 / string.h < prev    next >
C/C++ Source or Header  |  1992-05-15  |  4KB  |  144 lines

  1. /*
  2.  * String functions.
  3.  */
  4. #ifndef _STRING_H
  5. #define _STRING_H
  6.  
  7. #ifndef _COMPILER_H
  8. #include <compiler.h>
  9. #endif
  10.  
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15.  
  16. #ifndef _SIZE_T
  17. #define _SIZE_T __SIZE_TYPEDEF__
  18. typedef _SIZE_T size_t;
  19. #endif
  20.  
  21. #ifndef NULL
  22. #define NULL __NULL
  23. #endif
  24.  
  25. __EXTERN void *memcpy __PROTO((void *dst, const void *src, size_t size));
  26. __EXTERN void *memmove __PROTO((void *dst, const void *src, size_t size));
  27. __EXTERN int memcmp __PROTO((const void *s1, const void *s2, size_t size));
  28. __EXTERN void *memchr __PROTO((const void *s, int ucharwanted, size_t size));
  29. __EXTERN void *memset __PROTO((void *s, int ucharfill, size_t size));
  30.  
  31. __EXTERN char *strcpy __PROTO((char *dst, const char *src));
  32. __EXTERN char *strncpy __PROTO((char *dst, const char *src, size_t n));
  33. __EXTERN char *strcat __PROTO((char *dst, const char *src));
  34. __EXTERN char *strncat __PROTO((char *dst, const char *src, size_t n));
  35. __EXTERN int strcmp __PROTO((const char *scan1, const char *scan2));
  36. __EXTERN int strncmp __PROTO((const char *scan1, const char *scan2, size_t n));
  37. __EXTERN int strcoll __PROTO((const char *scan1, const char *scan2));
  38. __EXTERN size_t    strxfrm __PROTO((char *to, const char *from, size_t maxsize));
  39. __EXTERN char *strchr __PROTO((const char *s, int charwanted));
  40. __EXTERN size_t strcspn __PROTO((const char *s, const char *reject));
  41. __EXTERN char *strpbrk __PROTO((const char *s, const char *breakat));
  42. __EXTERN char *strrchr __PROTO((const char *s, int charwanted));
  43. __EXTERN size_t strspn __PROTO((const char *s, const char *accept));
  44. __EXTERN char *strstr __PROTO((const char *s, const char *wanted));
  45. __EXTERN char *strtok __PROTO((char *s, const char *delim));
  46. __EXTERN size_t strlen __PROTO((const char *scan));
  47. __EXTERN char *strerror __PROTO((int errnum));
  48.  
  49. #ifndef __STRICT_ANSI__
  50. /* 
  51.  * from henry spencers string lib
  52.  *  these dont appear in ansi draft sec 4.11
  53.  */
  54. __EXTERN void *memccpy __PROTO((void *dst, const void *src, int ucharstop, size_t size));
  55. __EXTERN char *strlwr __PROTO((char *string));
  56. /* CAUTION: there are assumptions elsewhere in the code that strrev()
  57.    reverses in-place
  58.  */
  59. __EXTERN char *strrev __PROTO((char *string));
  60. __EXTERN char *strdup __PROTO((const char *s));
  61.  
  62. /*
  63.  * V7 and BSD compatibility.
  64.  */
  65. __EXTERN char *index __PROTO((const char *s, int charwanted));
  66. __EXTERN char *rindex __PROTO((const char *s, int charwanted));
  67. __EXTERN void bcopy __PROTO((const void *src, void *dst, size_t length));
  68. __EXTERN int bcmp __PROTO((const void *src, const void *dst, size_t n));
  69. __EXTERN void bzero __PROTO((void *b, size_t n));
  70.  
  71. #ifdef __MINT__
  72. __EXTERN void _bcopy __PROTO((const void *src, void *dst, unsigned long length));
  73. __EXTERN int  _bcmp __PROTO((const void *s1, const void *s2, unsigned long length));
  74. __EXTERN void _bzero __PROTO((void *dst, unsigned long length));
  75. #else
  76. # ifdef __MSHORT__
  77. __EXTERN void lbcopy __PROTO((const void *src, void *dst, size_t length));
  78. __EXTERN int  lbcmp __PROTO((const void *s1, const void *s2, size_t length));
  79. __EXTERN void lbzero __PROTO((void *dst, size_t length));
  80. # endif
  81. #endif /* __MINT__ */
  82.  
  83. #endif /* __STRICT_ANSI__ */
  84.  
  85. #ifndef __MINT__
  86. #ifndef __STRICT_ANSI__
  87. #ifndef __MSHORT__
  88. #define lbcopy    bcopy
  89. #define lbcmp     bcmp
  90. #define lbzero    bzero
  91. #endif /* __MSHORT__ */
  92. #endif /* __STRICT_ANSI__ */
  93. #endif
  94.  
  95. /* some macro versions of functions. these are faster, but less
  96.    forgiving of NULLs and similar nasties. to use the library functions,
  97.    just #undef the appropriate things.
  98. */
  99.  
  100. #ifdef __GNUC_INLINE__
  101. # ifndef __cplusplus
  102.  
  103. static __inline__
  104. char *
  105. __strcat(char *dst, const char *src)
  106. {
  107.     register char *_dscan;
  108.  
  109.     for (_dscan = dst; *_dscan; _dscan++) ;
  110.     while (*_dscan++ = *src++) ;
  111.     return dst;
  112. }
  113.  
  114. static __inline__ 
  115. char *
  116. __strcpy(char *dst, const char *src)
  117. {
  118.     register char *_dscan = dst;
  119.     while (*_dscan++ = *src++) ;
  120.     return dst;
  121. }
  122.  
  123. static __inline__
  124. size_t
  125. __strlen(const char *scan)
  126. {
  127.     register const char *_start = scan+1;
  128.     while (*scan++) ;
  129.     return (size_t)((long)scan - (long)_start);
  130. }
  131.  
  132. #define strcat     __strcat
  133. #define strcpy     __strcpy
  134. #define strlen     __strlen
  135.  
  136. # endif /* !__cplusplus */
  137. #endif /* __GNUC_INLINE__ */
  138.  
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142.  
  143. #endif /* _STRING_H */
  144.